//
//  ShopGoodsDetailCell.m
//  ForestPack
//
//  Created by jimmy on 2018/7/30.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "ShopGoodsDetailCell.h"
#import "UIView+Utils.h"

@interface ShopGoodsDetailCell()

@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *detailLabel;
@property (nonatomic, strong) UILabel *moneyLabel;
@property (nonatomic, strong) UILabel *timeLabel;

@end

@implementation ShopGoodsDetailCell

+ (ShopGoodsDetailCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellID = @"ShopGoodsDetailCell";
    ShopGoodsDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[ShopGoodsDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        [cell createSubView];
    }
    
    return cell;
}

-(void)setShopGoodsDetailModel:(ShopGoodsDetailModel *)shopGoodsDetailModel
{
    _shopGoodsDetailModel = shopGoodsDetailModel;
    
    self.nameLabel.text = [@"商品名称：" stringByAppendingString:shopGoodsDetailModel.design_name];
    self.moneyLabel.text = [@"商品价格：" stringByAppendingString:shopGoodsDetailModel.price];
    if (shopGoodsDetailModel.edit_time) {
        self.timeLabel.text = [@"上架时间：" stringByAppendingString:[NSString stringWithFormat:@"%@",[HttpManager TimeStamp:shopGoodsDetailModel.edit_time]]];
    }
    self.detailLabel.text = shopGoodsDetailModel.design_des;
    CGFloat height = kGetStringHeight(shopGoodsDetailModel.design_des, CGSizeMake(SCREEN_WIDTH - 26 - 75, 60), Kfont(14));
    self.detailLabel.frame = CGRectMake(88, self.timeLabel.bottom + 5, SCREEN_WIDTH - 26 - 75, height + 4);
}

- (void)createSubView {
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(13, 5, SCREEN_WIDTH - 26, 20)];
    self.nameLabel.text = @"商品名称：包装纸箱设计";
    self.nameLabel.textColor = REXADECIMALCOLOR(@"#333333");
    self.nameLabel.font = Kfont(14);
    [self addSubview:self.nameLabel];
    
    self.moneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(13, self.nameLabel.bottom +5, SCREEN_WIDTH - 26, 20)];
    self.moneyLabel.textColor = REXADECIMALCOLOR(@"#333333");
    self.moneyLabel.font = Kfont(14);
    self.moneyLabel.text = @"商品价格:1200元";
    [self addSubview:self.moneyLabel];
    
    self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(13, self.moneyLabel.bottom + 5, SCREEN_WIDTH - 26, 20)];
    self.timeLabel.textColor = REXADECIMALCOLOR(@"#333333");
    self.timeLabel.font = Kfont(14);
    self.timeLabel.text = @"上架时间：2018-06-16  16:24";
    [self addSubview:self.timeLabel];
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(13, self.timeLabel.bottom + 5, 70, 20)];
    label.textColor = REXADECIMALCOLOR(@"#333333");
    label.font = Kfont(14);
    label.text = @"商品描述:";
    [self addSubview:label];
    
    self.detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(label.right + 5, self.timeLabel.bottom + 5, SCREEN_WIDTH - 26 - 75, 60)];
    self.detailLabel.textColor = REXADECIMALCOLOR(@"#333333");
    self.detailLabel.numberOfLines = 0;
    self.detailLabel.font = Kfont(14);
    self.detailLabel.text = @"专业设计三十年，专注包装设计，上课做高端订制，下课坐私人设计。物美价廉，只要10元。";
    [self addSubview:self.detailLabel];
    
}

@end
